package com.ruoyi.exam_major.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam_major.domain.TbExamMajor;
import com.ruoyi.exam_major.service.ITbExamMajorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报考专业信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/exam_major/exam_major")
public class TbExamMajorController extends BaseController
{
    @Autowired
    private ITbExamMajorService tbExamMajorService;

    /**
     * 查询报考专业信息列表
     */
    @PreAuthorize("@ss.hasPermi('exam_major:exam_major:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbExamMajor tbExamMajor)
    {
        startPage();
        List<TbExamMajor> list = tbExamMajorService.selectTbExamMajorList(tbExamMajor);
        return getDataTable(list);
    }

    /**
     * 导出报考专业信息列表
     */
    @PreAuthorize("@ss.hasPermi('exam_major:exam_major:export')")
    @Log(title = "报考专业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbExamMajor tbExamMajor)
    {
        List<TbExamMajor> list = tbExamMajorService.selectTbExamMajorList(tbExamMajor);
        ExcelUtil<TbExamMajor> util = new ExcelUtil<TbExamMajor>(TbExamMajor.class);
        util.exportExcel(response, list, "报考专业信息数据");
    }

    /**
     * 获取报考专业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam_major:exam_major:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbExamMajorService.selectTbExamMajorById(id));
    }

    /**
     * 新增报考专业信息
     */
    @PreAuthorize("@ss.hasPermi('exam_major:exam_major:add')")
    @Log(title = "报考专业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbExamMajor tbExamMajor)
    {
        return toAjax(tbExamMajorService.insertTbExamMajor(tbExamMajor));
    }

    /**
     * 修改报考专业信息
     */
    @PreAuthorize("@ss.hasPermi('exam_major:exam_major:edit')")
    @Log(title = "报考专业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbExamMajor tbExamMajor)
    {
        return toAjax(tbExamMajorService.updateTbExamMajor(tbExamMajor));
    }

    /**
     * 删除报考专业信息
     */
    @PreAuthorize("@ss.hasPermi('exam_major:exam_major:remove')")
    @Log(title = "报考专业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbExamMajorService.deleteTbExamMajorByIds(ids));
    }
}
